//app.js
App({

  globalData:{
    userInfo: {},
    openid: {},
  },

  onLaunch: function () {
    //版本不支持云开发 则跳转
    if (!wx.cloud) {
      wx.redirectTo({
        url: '../chooseLib/chooseLib',
      })
      return
    } else {
      wx.cloud.init({
        env: 'cloud1-ots36',
        traceUser: true,
      })
    }
  },
  //回调函数，获取openid
  appGetOpenId() {
    return new Promise((resolve, reject) =>{
      wx.cloud.callFunction({
        name: 'getOpenid',
        data: {}})
        .then(res=>{
          console.log('[云函数] [login] user openid: ', res.result.openid)
          this.globalData.openid = res.result.openid
          resolve(this.globalData.openid)
        })
    }
    )},
    
})
